//
//  MeViewController.swift
//  FXWB
//
//  Created by iSolar on 2017/3/9.
//  Copyright © 2017年 iSolar. All rights reserved.
//

import UIKit

private let btnCell = "MeTableViewCell"
class MeViewController: UITableViewController {

    var sections: [[Dictionary<String, Any>]] = [
        [
            [
                "image" : UIImage(named: "加好友")!,
                "title" : "新的好友",
                "arrowImg": UIImage(named: "arrow")!
            ]
        ],
        [
            [
                "image" : UIImage(named: "相册")!,
                "title" : "我的相册",
                "arrowImg": UIImage(named: "arrow")!
            ],
            [
                "image" : UIImage(named: "zan")!,
                "title" : "我的赞",
                "arrowImg": UIImage(named: "arrow")!
            ],
        ],
        [
            [
                "image" : UIImage(named: "wallet")!,
                "title" : "微博钱包",
                "arrowImg": UIImage(named: "arrow")!
            ],
            [
                "image" : UIImage(named: "运动")!,
                "title" : "微博运动",
                "arrowImg": UIImage(named: "arrow")!
            ],
            [
                "image" : UIImage(named: "流量")!,
                "title" : "免流量",
                "arrowImg": UIImage(named: "arrow")!
            ]
        ],
        [
            [
                "image" : UIImage(named: "fans")!,
                "title" : "粉丝服务",
                "arrowImg": UIImage(named: "arrow")!
            ],
            [
                "image" : UIImage(named: "头条")!,
                "title" : "粉丝头条",
                "arrowImg": UIImage(named: "arrow")!            ],
            ],
        [
            [
                "image" : UIImage(named: "草稿箱")!,
                "title" : "草稿箱",
                "arrowImg": UIImage(named: "arrow")!
            ],
            ],
        [
            [
                "image" : UIImage(named: "more")!,
                "title" : "更多",
                "arrowImg": UIImage(named: "arrow")!            ],
            ],
        ]

    @IBOutlet weak var headerView: UIView!
    @IBOutlet weak var icon: UIImageView!
    
    @IBOutlet weak var vipView: UIImageView!
    @IBOutlet weak var userType: UILabel!
    @IBOutlet weak var sign: UILabel!
    @IBOutlet weak var nickName: UILabel!
    @IBOutlet weak var wbNumber: UILabel!
    @IBOutlet weak var collectionNum: UILabel!
    @IBOutlet weak var fansNum: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        icon.layer.cornerRadius = 30
        icon.layer.masksToBounds = true
        tableView.register(UINib(nibName:"MeTableViewCell", bundle: nil), forCellReuseIdentifier: btnCell)
    }

}

extension MeViewController {
    override func numberOfSections(in tableView: UITableView) -> Int {
        return sections.count
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return sections[section].count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // 1.创建cell
        let cell = tableView.dequeueReusableCell(withIdentifier: btnCell) as! MeTableViewCell
        cell.selectionStyle = UITableViewCellSelectionStyle.none
        cell.iconImg = self.sections[indexPath.section][indexPath.row]["image"] as? UIImage
        cell.titleLabel.text = self.sections[indexPath.section][indexPath.row]["title"] as? String
        
        return cell;
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }

//    //设置Cell选中背景
//    func tableView(tableView: UITableView, didHighlightRowAtIndexPath indexPath: NSIndexPath) {
//        
//        let cell = tableView.cellForRow(at: indexPath as IndexPath)
//        cell?.backgroundColor = UIColor.white
//    }

}
